package com.kly.test.function.testActivity

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.kly.test.base.BaseVMListActivity
import com.kly.test.base.adpater.BaseRecyclerAdapter
import com.kly.test.databinding.ActivityListBinding
import com.kly.test.function.MainViewModel
import com.kly.test.function.like.adapter.MyAdapter
import com.scwang.smart.refresh.layout.SmartRefreshLayout

class ListActivity : BaseVMListActivity<String,ActivityListBinding, MainViewModel>(ActivityListBinding::inflate, MainViewModel::class.java
) {
    override fun getMyAdapter(): BaseRecyclerAdapter<String, *> {
        return MyAdapter()
    }

    override fun getSmartRefreshLayout(): SmartRefreshLayout {
        return binding.refreshLayout
    }

    override fun getRecyclerView(): RecyclerView {
        return binding.recyclerView
    }

    override fun onRefresh() {

        loadData(getData())
    }

    override fun getLayoutManager(): RecyclerView.LayoutManager {
        return GridLayoutManager(this,3)
    }
    override fun onLoadMore() {

        loadData(getData())
    }

    override fun initData() {

        loadData(getData())
    }
    fun getData(): ArrayList<String> {
        val items = ArrayList<String>()
        for (i in 0..20) {
            items.add(i.toString())
        }
        return items
    }
}